package main

import (
	"fmt"
	"log"
	"net/http"
	"time"

	dash "gitee.com/dark.H/DashViewer/DataServer"
	"github.com/zserge/lorca"
)

func main() {
	// Create UI with basic HTML passed via data URI
	// htmlString, err := ioutil.ReadFile("test.html")
	go func() {
		http.HandleFunc("/", dash.IndexHandler)
		http.HandleFunc("/files", dash.FileHandler)
		http.HandleFunc("/ws", dash.WsAPI)
		http.HandleFunc("/search", dash.SearchHandler)
		http.HandleFunc("/menu", dash.GetMenuHandler)
		http.HandleFunc("/graph", dash.GraphDataOperHandler)
		http.ListenAndServe(":38181", nil)
	}()
	time.Sleep(time.Second * 2)
	ui, err := lorca.New("", "", 2200, 1250)
	ui.Load(fmt.Sprintf("http://localhost:38181"))
	if err != nil {
		log.Fatal(err)
	}
	defer ui.Close()
	// Wait until UI window is closed
	<-ui.Done()
}
